<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

    <title> - 登录</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="${pageContext.request.contextPath}/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/css/animate.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/css/style.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/css/login.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>

</head>

<body class="signin">
    <div class="signinpanel">
        <div class="row">
            <div class="col-sm-12">
                <form method="post" id="formId" onsubmit="return false">
                    <h4 class="no-margins">登录：</h4>
                    <p class="m-t-md">登录到H+后台主题UI框架</p>
                    <input type="text" id="nameId" name="name" class="form-control uname" placeholder="用户名" />
                    <input type="password" id="passwordId" name="password" class="form-control pword m-b" placeholder="密码" />
                    <a href="">忘记密码了？</a>
                    <button class="btn btn-success btn-block" onclick="login()">登录</button>
                </form>
            </div>
        </div>
        <div class="signup-footer">
            <div class="pull-left">
                &copy; hAdmin
            </div>
        </div>
    </div>
</body>
	<script src="${pageContext.request.contextPath}/static/lib/jquery/jquery-1.11.1.js" type="text/javascript" charset="utf-8"></script>
    <script src="<%=request.getContextPath()%>/static/lib/layer/layer.js"></script>
    <script src="<%=request.getContextPath()%>/static/common/mylayer.js"></script>
	<script type="text/javascript">
		function login(){
			var name = $("#nameId").val();
			var password = $("#passwordId").val();
			if(name == "" || name == null || name == undefined){
				mylayer.error("用户名不能为空");
				return;
			}
			var reg = /^[0-9a-zA-Z]{4,8}$/;
			if(name.match(reg) == null){
				mylayer.error("用户名为4-8位字母或者数字");
				return;
			}
			if(password == "" || password == null || password == undefined){
				mylayer.error("密码不能为空");
				return;
			}
			console.log($("formId").serialize());
			$.ajax({
				type : "POST",
				dataType : "json",
				data : $("#formId").serialize(),
				url : "${pageContext.request.contextPath}/user/login.action",
			    success : function(resp){
			    	if(resp.code === 0){
			    		mylayer.successUrl(resp.msg,"${pageContext.request.contextPath}/user/index.action");
			    	} else {
			    		mylayer.error(resp.msg);
			    	}
			    }
			})
		}
	</script>
</html>
